﻿using DXApplicationTangche.UC.订单一览新.订单预览新.service;
using DXApplicationTangche.UC.门店下单.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DXApplicationTangche.UC.标签打印.model
{
    /// <summary>
    /// 有多个地方使用同一方法，因为有多个返回值所以不能写private方法，单独新建一个类，实例化后调用
    /// </summary>
    public class 刺绣内容添加至备注Model
    {
        public List<DTODesignPoints设计点> dTODesignPoints { get; set; } = new List<DTODesignPoints设计点>();
        public List<DTODesignPoints> designPoints { get; set; } = new List<DTODesignPoints>();

        public String str备注 { get; set; }
        public 刺绣内容添加至备注Model(List<DTODesignPoints设计点> dTODesignPoints, String remarks)
        {
            //备注为全局变量，根据REMARKS赋初值
            this.dTODesignPoints = dTODesignPoints;
            this.str备注 = remarks;
            String str刺绣 = "";
            Boolean has刺绣 = false;
            foreach (DTODesignPoints设计点 DTODesignPoints in dTODesignPoints)
            {
                //当刺绣内容itemCd不为空，找到刺绣有关的5个设计点
                if (
                    !String.IsNullOrEmpty(DTODesignPoints.itemValue) &&
                    !"4SMP".Equals(DTODesignPoints.itemValue) &&
                    !"4SMS".Equals(DTODesignPoints.itemValue) &&
                    !"4SMO".Equals(DTODesignPoints.itemValue) &&
                    !"4SMC".Equals(DTODesignPoints.itemValue) &&
                    !"4SMT".Equals(DTODesignPoints.itemValue)
                    )
                {
                    dTODesignPoints.Add(DTODesignPoints);
                }
                //将刺绣内容添加到备注
                if (
                    "4SMP".Equals(DTODesignPoints.itemValue) ||
                    "4SMS".Equals(DTODesignPoints.itemValue) ||
                    "4SMO".Equals(DTODesignPoints.itemValue) ||
                    "4SMC".Equals(DTODesignPoints.itemValue)
                    )
                {
                    str刺绣 += "|" + DTODesignPoints.itemTypeNameCn + ":" + DTODesignPoints.name;
                }
                //除刺绣内容是optionValue，其他是name
                else if ("4SMT".Equals(DTODesignPoints.itemValue))
                {
                    has刺绣 = true;
                    str刺绣 += "|" + DTODesignPoints.itemTypeNameCn + ":" + DTODesignPoints.optionValue + "   ";
                }
            }
            // 刺绣转备注 
            if(has刺绣)
                this.build备注(str刺绣);
        }
        public 刺绣内容添加至备注Model(List<DTODesignPoints> designPoints, String remarks)
        {
            //备注为全局变量，根据REMARKS赋初值
            this.designPoints = designPoints;
            this.str备注 = remarks;
            String str刺绣 = "";
            Boolean has刺绣 = false;
            foreach (DTODesignPoints设计点 DTODesignPoints in dTODesignPoints)
            {
                //当刺绣内容itemCd不为空，找到刺绣有关的5个设计点
                if (
                    !String.IsNullOrEmpty(DTODesignPoints.itemValue) &&
                    !"4SMP".Equals(DTODesignPoints.itemValue) &&
                    !"4SMS".Equals(DTODesignPoints.itemValue) &&
                    !"4SMO".Equals(DTODesignPoints.itemValue) &&
                    !"4SMC".Equals(DTODesignPoints.itemValue) &&
                    !"4SMT".Equals(DTODesignPoints.itemValue)
                    )
                {
                    dTODesignPoints.Add(DTODesignPoints);
                }
                //将刺绣内容添加到备注
                if (
                    "4SMP".Equals(DTODesignPoints.itemValue) ||
                    "4SMS".Equals(DTODesignPoints.itemValue) ||
                    "4SMO".Equals(DTODesignPoints.itemValue) ||
                    "4SMC".Equals(DTODesignPoints.itemValue)
                    )
                {
                    str刺绣 += "|" + DTODesignPoints.itemTypeNameCn + ":" + DTODesignPoints.name;
                }
                //除刺绣内容是optionValue，其他是name
                else if ("4SMT".Equals(DTODesignPoints.itemValue))
                {
                    has刺绣 = true;
                    str刺绣 += "|" + DTODesignPoints.itemTypeNameCn + ":" + DTODesignPoints.optionValue+"   ";
                }
            }
            // 刺绣转备注 
            if (has刺绣)
                this.build备注(str刺绣);
        }

        /// <summary>
        /// 刺绣转备注
        /// </summary>
        /// <param name="str刺绣"></param>
        private void build备注(String str刺绣) {
            if (!String.IsNullOrEmpty(str刺绣))
            {
                this.str备注 += "\n刺绣内容:" + str刺绣;
            }
        }
    }
}
